﻿@{
    Layout = "~/Views/Shared/_FormWhite.cshtml";
}

<div class="wrapper animated fadeInRight">
    <form id="form" class="form-horizontal m">
        @*<div class="form-group">
            <label class="col-sm-2 control-label ">MsId<font class="red"> *</font></label>
            <div class="col-sm-8">
                <input id="msId" col="MsId" type="text" class="form-control" />
            </div>
        </div>
        *@
        <div class="form-group">
            <label class="col-sm-2 control-label ">姓名</label>
            <div class="col-sm-8">
                <input id="msName" col="MsName" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">联系电话</label>
            <div class="col-sm-8">
                <input id="msHone" col="MsHone" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group" style="display:none">
            <label class="col-sm-2 control-label ">地址</label>
            <div class="col-sm-8">
                <input id="msAddress" col="MsAddress" type="text" class="form-control" />
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label ">标题</label>
            <div class="col-sm-8">
                <input id="msType" col="MsType" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">留言内容</label>
            <div class="col-sm-8">

                <textarea id="msContent" col="MsContent" class="form-control"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">留言时间</label>
            <div class="col-sm-4">
                <input id="msAdddatetime" col="MsAdddatetime" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">回复内容</label>
            <div class="col-sm-8">
                <textarea id="msReplycontent" col="MsReplycontent" class="form-control"></textarea>

            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">回复时间</label>
            <div class="col-sm-4">
                <input id="msUpdatetime" col="MsUpdatetime" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">是否推荐</label>
            <div class="col-sm-8">
                <select id="msUid" col="MsUid">
                    <option value="1">是</option>
                    <option value="0">否</option>
                </select>
               
            </div>
        </div>
    </form>
</div>

<script type="text/javascript">
    var id = ys.request("id");
    laydate.render({ elem: '#msUpdatetime', type: 'datetime', format: 'yyyy-MM-dd HH:mm' });

    $(function () {
        getForm();

        $('#form').validate({
            rules: {
                msId: { required: true }
            }
        });
    });

    function getForm() {
        if (id > 0) {
            ys.ajax({
                url: '@Url.Content("~/OrganizationManage/Message/GetFormJson")' + '?id=' + id,
                type: 'get',
                success: function (obj) {
                    if (obj.Tag == 1) {
                        obj.Result.MsUpdatetime = ys.formatDate(obj.Result.MsUpdatetime, "yyyy-MM-dd HH:mm");
                        obj.Result.MsAdddatetime = ys.formatDate(obj.Result.MsAdddatetime, "yyyy-MM-dd HH:mm");
                        $("#form").setWebControls(obj.Result);

                    }
                }
            });
        }
        else {
            var defaultData = {};
            defaultData.MsAdddatetime = '@DateTime.Now.ToString("yyyy-MM-dd HH:mm")';
            defaultData.MsUpdatetime = '@DateTime.Now.ToString("yyyy-MM-dd HH:mm")';
            $("#form").setWebControls(defaultData);
            $('#form').setWebControls(defaultData);
        }
    }

    function saveForm(index) {
        if ($('#form').validate().form()) {
            var postData = $('#form').getWebControls({ Id: id });
            ys.ajax({
                url: '@Url.Content("~/OrganizationManage/Message/SaveFormJson")',
                type: 'post',
                data: postData,
                success: function (obj) {
                    if (obj.Tag == 1) {
                        ys.msgSuccess(obj.Message);
                        parent.searchGrid();
                        parent.layer.close(index);
                    }
                    else {
                        ys.msgError(obj.Message);
                    }
                }
            });
        }
    }
</script>

